package sng.modules.view.components.city.cursor
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class CityCursorManager
	{
		
		private var normalCursor:Bitmap=new Bitmap();
		private var addCursor:Bitmap=new CityCursorAsset.AddCursor();
		private var deleteCursor:Bitmap=new CityCursorAsset.DeleteCursor();
		private var moveCursor:Bitmap=new CityCursorAsset.MoveCursor();
		private var turnCursor:Bitmap=new CityCursorAsset.TurnCursor();
		private var buildDisenableCursor:Bitmap=new CityCursorAsset.BuildDisenableCursor();
		private var upgradeCursor:Bitmap=new CityCursorAsset.UpgradeCursor();
		private var cutCursor:Bitmap=new CityCursorAsset.CutCursor();
		private var sowCursor:Bitmap=new CityCursorAsset.SowCursor();
		private var appleCursor:Bitmap=new CityCursorAsset.AppleCursor();
		
		private var mouseCursorContainer:Sprite;

		
		
		private static var _instance:CityCursorManager;
		
		private var _currentCursor:Bitmap;
		private var _currentCursorType:String;
		
		public function CityCursorManager()
		{
		}
		
		public static function getInstance():CityCursorManager
		{
			if(_instance==null)
				_instance=new CityCursorManager();
			return _instance;
		}
		
		public function currentCursorType():String
		{
			return _currentCursorType;
		}
		
		
		public function setCursor(type:String):void
		{
			switch(type)
			{
				case CityCursor.ADD_CURSOR:
					_currentCursor=addCursor;
					break;
				case CityCursor.MOVE_CURSOR:
					_currentCursor=moveCursor;
					break;
				case CityCursor.DELETE_CURSOR:
					_currentCursor=deleteCursor;
					break;
				case CityCursor.UPGRADE_CURSOR:
					_currentCursor=upgradeCursor;
					break;
				case CityCursor.TURN_CURSOR:
					_currentCursor=turnCursor;
					break;
				case CityCursor.BUILD_DISENABLE_CURSOR:
					_currentCursor=buildDisenableCursor;
					break;
				case CityCursor.NORMAL_CURSOR:
					_currentCursor=normalCursor;
					break;
				case CityCursor.CUT_CURSOR:
					_currentCursor=cutCursor;
					break;
				case CityCursor.SOW_CURSOR:
					_currentCursor=sowCursor;
					break;
				case CityCursor.APPLE_CURSOR:
					_currentCursor=appleCursor;
					break;
			}
			_currentCursorType=type;
			if(mouseCursorContainer!=null)
			{
				if(mouseCursorContainer.getChildAt(0)!=_currentCursor)
				{
					mouseCursorContainer.removeChildAt(0);
					mouseCursorContainer.addChild(_currentCursor);
				}
			}
		}
		
		public function initCursorContainer(_mouseCursorContainer:Sprite):void
		{
			mouseCursorContainer=_mouseCursorContainer;
			_currentCursor=normalCursor;
			mouseCursorContainer.addChild(_currentCursor);
		}
	}
}